﻿using IceZero.DataStore.Models.Enums;
using NHibernate;
using NHibernate.Classic;
using NHibernate.Mapping.Attributes;
using NHibernate.Type;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceZero.DataStore.Models
{
    /// <summary>
    /// 应用配置表
    /// </summary>
    [Class(Table = "IceZero_AppConfig")]
    public class AppConfig
    {
        public AppConfig()
        {

        }

        /// <summary>
        /// 配置项键
        /// </summary>
        [Id(0, Name = "ConfigKey", TypeType = typeof(string), UnsavedValue = "0", Length = 255)]
        [Key(1, Unique = true)]
        [Generator(2, Class = "assigned")]
        public virtual string ConfigKey { get; set; }

        /// <summary>
        /// 配置项值
        /// </summary>
        [Property(Column = "ConfigValue", TypeType = typeof(string), Length = 8000)]
        public virtual string ConfigValue { get; set; }

        /// <summary>
        /// 配置项值
        /// </summary>
        /// <remarks>EnumStringType 可以让存储到数据库的枚举值是字面量，而不是int数字</remarks>
        [Property(Column = "ConfigValueType", TypeType = typeof(EnumStringType<ConfigValueType>), Length = 255)]
        public virtual ConfigValueType ConfigValueType { get; set; } = ConfigValueType.Text;

        /// <summary>
        /// 配置项备注
        /// </summary>
        [Property(Column = "ConfigRemark", TypeType = typeof(string), Length = 2000)]
        public virtual string ConfigRemark { get; set; }
    }
}
